package solution2;

import java.util.Scanner;

/**
 * 输入描述:
 * m n
 * m个整数
 * n个整数
 * 例如：
 * 3 3
 * 1 2 3
 * 1 2 3
 * 输出：
 * 2 4 6
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m = sc.nextInt();
            int n = sc.nextInt();
            ListNode l1 = new ListNode(0);
            ListNode r1 = l1;
            for (int i = 0 ; i < m; i++) {
                l1.next = new ListNode(sc.nextInt());
                l1 = l1.next;
            }
            ListNode l2 = new ListNode(0);
            ListNode r2 = l2;
            for (int i = 0; i < n; i++) {
                l2.next = new ListNode(sc.nextInt());
                l2 = l2.next;
            }
//            Solution s = new Solution();
            ListNode ans = new ListNode(0);
//            ans = s.addTwoNumbers(r1.next, r2.next);
//            while (ans != null) {
//                System.out.print(ans.val+ " ");
//                ans = ans.next;
//            }
            Solution2 s2 = new Solution2();
            ans = s2.addTwoNumbers(r1.next, r2.next);
            while (ans != null) {
                System.out.print(ans.val+ " ");
                ans = ans.next;
            }
        }
    }
}
